home *** CD-ROM | disk | FTP | other *** search
- Path: nebula.broadvision.com!usenet
- From: patrick@broadvision.com (Patrick Horgan)
- Newsgroups: comp.sources.wanted,comp.lang.c,comp.unix.programmer
- Subject: Re: Seek unix2dos.c OR help with tr
- Date: 21 Mar 1996 17:24:19 GMT
- Organization: The quite unorganized Patrick
- Message-ID: <4is3c3$jmp@ns.broadvision.com>
- References: <danpop.826917054@rscernix>
- Reply-To: patrick@broadvision.com
- NNTP-Posting-Host: star.broadvision.com
-
- In article <danpop.826917054@rscernix>, danpop@mail.cern.ch (Dan Pop) writes:
- >Moreover, 0x1f is not a magic number _in this context_ any more than 2
- >is a magic number in a binary search algorithm or 3.1415926 is a magic
- >number when computing the circumference of a circle. All of them are
- >natural constants
-
- I agree...and it's the way I would do it as well.
-
- >
- >As for Kazimir's example, a "better" definition would be:
- >
- >#define CTRL(C) ((C) - 'A' + 1)
-
- If I went down this path I'd choose ((C) - '@' )...somehow the + 1 seems as if it
- will lead to further silly misunderstandings by junior programmers...I much prefer
- anding off the upper bits though...anding with 0x3f is better and even works for
- characters generated on some keyboards whose code is over 127...the subtraction
- method won't.
-
- --
-
- Patrick J. Horgan patrick@broadvision.com Have horse will ride.
- Opinions mine, not my employer's except by most bizarre coincidence.
-
-
-